import service from "@/util/service";

// 登录
export function login(params:{username:string,password:string}){
    return service({
        url:'login',
        method:'post',
        params
    })
}
// 获取用户列表
export  function  getUserList(params:any = { pagenum: 1, pagesize: 5, query: '' }){
    return service({
            url:'users',
            method:'get',
            params
        })
}

// 添加用户信息
// data数据传输 post
export function addUsers(data:{
    username:string,
    password:string,
    email:string, //可以为空
    mobile:string //可以为空
    
}){
    return service({
        url:'/users',
        method:'post',
        data
    })
}

// 编辑用户信息
export function EditUser (id:number,data:{
    email:string,
    mobile:string
}){
    return service({
        url:'/users/'+id,
        method:'put',
        data
    })
}

// 修改用户状态
export function  setUsersState(uId:number,type:boolean){
    return service({
        url:'/users/'+uId+'/state/'+type,
        method:'put'
    })
}


// 删除用户信息
export function DeleteUser(id:number){
    return service({
        url:'/users/'+id,
        method:'delete',

    })
} 


// 分配用户角色
export function usersPower(id:number,data:{}){
    return service({
        url:'/users/'+id+'/role',
        method:'put',
        data
    })
}